< previous page page_164 next page >

Page 164
The following example is from the Do While command button:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdDoWhile_Click ()
   Dim intNumber As Integer

   Cls
   intNumber = 1
   Do While intNumber < 10
      Print intNumber
      intNumber = intNumber + 1
   Loop
End Sub
While . . . Wend
The While...Wend loop is exactly the same as the Do While loop. Its not used too much anymore, but in previous versions of the BASIC language, it was used quite a lot. Therefore, Visual Basic includes this syntax to maintain backward compatibility. This construct is actually not even in the help anymore which means Visual Basic will probably not support it in a future version. Heres the syntax:
9f31265bb40b592b1929e18a47ab28e5.gif
While <Cond>
    <Statement Block>
Wend
The following example is from the While/Wend command button:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdWhileWend_Click ()
   Dim intNumber As Integer

   Cls
   intNumber = 1
   While intNumber < 10
      Print intNumber
      intNumber = intNumber + 1
   Wend
End Sub

 
< previous page page_164 next page >

If you like this book, buy it!